
let Textarea = document.querySelector(".textarea");

let ContenBox = document.querySelector(".ContenBox");

Textarea.onkeydown = function(e){  
    if(e.keyCode === 13){
        let TextareaValue = Textarea.value;
        if(TextareaValue === ""){
            alert("空数据");
            this.blur();
        }
        else if(TextareaValue.length >= 160){
            alert("最大的输入字数限制为 160 个字");
            this.blur();
            Textarea.value = "";
        }
        else{
            ContenBox.insertAdjacentHTML("beforeend",`<div>
                                                <div class="cont">
                                                ${TextareaValue}
                                                </div></div>`);
            let contS = document.querySelectorAll(".cont");
            contS[contS.length-1].scrollIntoView(true);
            Textarea.value = "";
            this.blur();
        }     
    }

}
